package com.club.controller;

import com.club.entity.PageBean;
import com.club.entity.R;
import com.club.service.TActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 活动管理controller
 *
 * @author zhangfc
 * @date 2022/12/14 15:06
 */
@RequiredArgsConstructor
@Api(tags = "活动管理controller")
@RestController
@RequestMapping("/activity")
public class TActivityController {

    private final TActivityService tActivityService;


    /**
     * 活动提交审核
     *
     * @param actMap 参数
     * @return R
     */
    @PostMapping("/submitActivity")
    @ApiOperation("活动提交审核")
    public R submitActivity(@RequestBody Map<String, Object> actMap) {
        return tActivityService.submitAct(actMap);
    }

    /**
     * 分页获取活动信息
     *
     * @param pageBean 分页信息
     * @return R
     */
    @PostMapping("/listTActivity")
    @ApiOperation("分页获取活动信息")
    public R listTActivity(@RequestBody PageBean pageBean) {
        return tActivityService.listTactivity(pageBean);
    }


    /**
     * 活动审核
     *
     * @param actId 主键
     * @param type  类型 1-审核通过 2-审核不通过
     * @return R
     */
    @GetMapping("/auditAct")
    @ApiOperation("活动审核")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "活动主键", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "type", value = "类型 1-审核通过 2-审核不通过", required = true, paramType = "query", dataType = "String")
    })
    public R auditAct(@RequestParam("id") int actId, @RequestParam("type") String type) {
        return tActivityService.auditAct(actId, type);
    }

    /**
     * 根据id集合批量删除活动列表
     *
     * @param ids 主键集合
     * @return R
     */
    @PostMapping("/deleteByIds")
    @ApiOperation("根据id集合批量删除活动列表")
    @ApiImplicitParam(name = "ids", value = "活动主键集合", required = true, paramType = "body", dataType = "List")
    public R deleteByIds(@RequestBody List<Integer> ids) {
        return tActivityService.deleteByIds(ids);
    }

    /**
     * 根据用户id查询该用户参加的活动列表
     *
     * @param userId 用户id
     * @return R
     */
    @GetMapping("/listActByUserId")
    @ApiOperation("根据用户id查询活动列表")
    @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "Integer")
    public R listActByUserId(@RequestParam("userId") int userId) {
        return tActivityService.listActByUserId(userId);
    }

    /**
     * 根据活动主键id查询活动详情
     *
     * @param actId 活动主键id
     * @return R
     */
    @GetMapping("/msgByActId/{actId}")
    @ApiOperation("根据活动主键id查询活动详情")
    @ApiImplicitParam(name = "actId", value = "活动主键", required = true, paramType = "query", dataType = "Integer")
    public R msgByActId(@PathVariable("actId") int actId) {
        return tActivityService.msgByActId(actId);
    }

}
